dta <- read.csv("PK.csv")
head(dta)
## ID TIME AMT DV MDV
## 1 1 0.00 0 0.00 0
## 2 1 0.00 4 0.00 1
## 3 1 0.33 0 9.40 0
## 4 1 0.66 0 13.71 0
## 5 1 1.00 0 16.52 0
## 6 1 1.50 0 29.36 0
str(dta)
## 'data.frame': 456 obs. of 5 variables:
## $ ID : num 1 1 1 1 1 1 1 1 1 1 ...
## $ TIME: num 0 0 0.33 0.66 1 1.5 2 3 4 6 ...
## $ AMT : num 0 4 0 0 0 0 0 0 0 0 ...
## $ DV : num 0 0 9.4 13.7 16.5 ...
## $ MDV : num 0 1 0 0 0 0 0 0 0 0 ...
plot(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0])
plot(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], log="y")
## Warning in xy.coords(x, y, xlabel, ylabel, log): 86 y values <= 0 omitted
## from logarithmic plot
plot(dta$TIME[dta$MDV==0], log(dta$DV[dta$MDV==0]))
plot(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0]
, xlab="Time (hr)", ylab="Concentration (ng/mL)"
, type="o", pch=2, col=1, main="PK time-course of Drug X"
, xlim =c(-2,218), ylim=c(0,80))
plot(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], axes=F,
, xlab="Time (hr)", ylab="Concentration (ng/mL)"
, type="o", pch=2, col=1, main="PK time-course of Drug X"
, xlim =c(-2,218), ylim=c(0,80))
axis(1, at=seq(0, 218, 24))
axis(2)
box()
d.demog <- read.csv("DEMOG.csv")
hist(d.demog$HT)
hist(d.demog$HT, breaks=10)
hist(d.demog$HT, nclass=10)
hist (d.demog$HT, probability=TRUE, breaks=10)
lines(density(d.demog$HT))
hist (d.demog$HT, probability=TRUE, breaks=9, xaxt="n"
, main="Histogram for Height", xlab="Height (cm)", ylab="Probability (%)")
axis(1, at=seq(min(d.demog$HT), max(d.demog$HT), 3))
lines(density(d.demog$HT))
hist (d.demog$HT, probability=TRUE, breaks=9, xaxt="n"
, main="Histogram for Height", xlab="Height (cm)", ylab="Probability (%)"
, col = "lightblue", border = "pink")
axis(1, at=seq(min(d.demog$HT), max(d.demog$HT), 3))
lines(density(d.demog$HT))
boxplot(d.demog$WT)
boxplot(d.demog$WT ~ d.demog$SEX)
boxplot(split(d.demog$WT, d.demog$SEX))
boxplot(WT ~ SEX, data=d.demog)
boxplot(d.demog$WT ~ d.demog$SEX
, names=c("Male","Female"), ylab="AGE, year", ylim=c(min(d.demog$WT)-2, max(d.demog$WT)+2)
, col="pink")
boxplot(d.demog$WT ~ d.demog$SEX
, names=c("Male","Female"), ylab="AGE, year", ylim=c(min(d.demog$WT)-2, max(d.demog$WT)+2)
, col=c("lightblue", "salmon"), width=c(0.6, 1))
-varwidth: if varwidth is TRUE, the boxes are drawn with widths proportional to the square-roots of the number of observations in the groups.
boxplot(d.demog$WT ~ d.demog$SEX
, names=c("Male","Female"), ylab="AGE, year", ylim=c(min(d.demog$WT)-2, max(d.demog$WT)+2)
, col=c("lightblue", "salmon")
, varwidth=TRUE)
barplot(d.demog$HT)
VADeaths
## Rural Male Rural Female Urban Male Urban Female
## 50-54 11.7 8.7 15.4 8.4
## 55-59 18.1 11.7 24.3 13.6
## 60-64 26.9 20.3 37.0 19.3
## 65-69 41.0 30.9 54.6 35.1
## 70-74 66.0 54.3 71.1 50.0
barplot(VADeaths, border = "dark blue")
barplot(VADeaths, col = rainbow(20))
barplot(VADeaths, col = heat.colors(8))
barplot(VADeaths, col = gray.colors(4))
barplot(VADeaths, col = gray.colors(4), log="x")
barplot(VADeaths, col = gray.colors(4), log="y")
barplot(VADeaths, col = gray.colors(4), log="xy")
drug.X.market <- c(0.12, 0.29, 0.32, 0.22, 0.11, 0.28)
names(drug.X.market) <- c("South Korea","China","USA","Japan","Austria","EU")
pie(drug.X.market)
pct.95 <- read.csv("pct95.csv")
matplot(pct.95[,1], pct.95[,2:ncol(pct.95)], pch=1)
matplot(pct.95[,1], pct.95[,2:ncol(pct.95)], pch=1, col=c(1,2,1), type="l", lty=1, lwd=c(1,2,1))
pairs(d.demog)
pairs(d.demog, panel = panel.smooth)
panel.cor <- function(x, y, digits=2, prefix="", cex.cor)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r = (cor(x, y))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 1.5
text(0.5, 0.5, txt, cex = 1.5)
}
pairs(d.demog, lower.panel=panel.smooth, upper.panel=panel.cor)
plot(pct.95$TIME, pct.95$PCT50, main="PK of Drug X"
, type="l", xlab="Time (h)", ylab="Concentration (ng/ml)"
, ylim=range(0,80), lty=1, col="red", lwd=2)
plot(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], main="PK of Drug X"
, type="n", xlab="Time (h)", ylab="Concentration (ng/ml)"
, ylim=range(0,80))
points(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], pch = 16, cex=0.8)
lines(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], col="black", lwd=1)
abline(40, 0, col="red", lty=2) # abline(a,b): y=a+b*x
legend("topright", legend=c("Individual concentrations")
, lty=1, col="black")
plot(c(1, 10), c(1, 6), type = "n")
polygon(c(2,8,8,2), c(5,4,3,2), col="lightgreen")
plot(c(1, 9), 1:2, type = "n")
polygon(1:9, c(2,1,2,1,1,2,1,2,1),
col = c("red", "blue"),
border = c("green", "yellow"),
lwd = 3, lty = c("dashed", "solid"))
pdf("PK_of_Drug_X.pdf")
plot(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], main="PK of Drug X"
, type="n", xlab="Time (h)", ylab="Concentration (ng/ml)"
, ylim=range(0,80))
points(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], pch = 16, cex=0.8)
lines(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], col="black", lwd=1)
abline(40, 0, col="red", lty=2) #abline(a,b): y=a+b*x
legend("topright", legend=c("Individual concentrations")
, lty=1, col="black")
dev.off()
## quartz_off_screen
## 2
png("PK_of_Drug_X.png")
plot(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], main="PK of Drug X"
, type="n", xlab="Time (h)", ylab="Concentration (ng/ml)"
, ylim=range(0,80))
points(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], pch = 16, cex=0.8)
lines(dta$TIME[dta$MDV==0], dta$DV[dta$MDV==0], col="black", lwd=1)
abline(40, 0, col="red", lty=2) #abline(a,b): y=a+b*x
legend("topright", legend=c("Individual concentrations")
, lty=1, col="black")
dev.off()
## quartz_off_screen
## 2